package com.example.wanandroid_copy2.ui.article.data

import androidx.lifecycle.MutableLiveData
import com.example.wanandroid_copy2.common.BaseObserver
import com.example.wanandroid_copy2.common.BaseResponse
import com.example.wanandroid_copy2.common.api.ApiRepository
import com.example.wanandroid_copy2.common.network.State
import com.example.wanandroid_copy2.common.utils.execute

open class ArticleRepository(val loadState : MutableLiveData<State>) : ApiRepository() {

    fun collect(position: Int,liveData : MutableLiveData<BaseResponse<Any>>){
        apiService.collect(position).execute(BaseObserver(liveData,loadState,this))
    }

    fun unCollect(position: Int,liveData: MutableLiveData<BaseResponse<Any>>){
        apiService.unCollect(position).execute(BaseObserver(liveData,loadState,this))
    }

}